<template>
  <div>
    <div>{{teacher.name}}</div>
    <div>{{teacher.age}}</div>
    <div>{{teacher.salary}}</div>
    <button @click="mm">过了一年</button>
  </div>
</template>

<script>
export default {
  // 组件的配置项中，除了data是函数，其他一律是对象
  data () {
    return {
      teacher:{
        name:"harry",
        age:28,
        salary:3000
      }

    }
  },
  methods: {
    mm() {
      this.teacher.age += 1
      this.teacher.salary += 500
    }
  },
  //除了data以外所有的配置项都是属性都用：
  watch: {
    //要监听复杂数据类型的话，要准确到属性
    "teacher.age" (newVal) {
      if(newVal === 40 ) {
        alert('您该退休了'+"您的年纪是"+this.teacher.age+"您的工资是"+this.teacher.salary)
      }
    }

  }
}
</script>

<style>

</style>